package com.fresh.api;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fresh.common.annotation.IgnoreAuth;
import com.fresh.entity.ReportResult;
import com.fresh.utils.PropertiesUtils;
import com.itextpdf.awt.AsianFontMapper;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

@RequestMapping({ "/pdf" })
@Controller
public class PdfController {
	private static final Logger log = LoggerFactory.getLogger(PdfController.class);
	
	@IgnoreAuth
	@RequestMapping({ "printPdf" })
	public String pdf(HttpServletRequest request,ReportResult reportResult){
		log.info("开始打印");
		//模拟列表数据
		List<String[]> list = new ArrayList<>();
		
		String[] ss1={"呼出电话总数",reportResult.getZhuCallOne(),reportResult.getZhuCallTwo(),reportResult.getZhuCallThree()};
		String[] ss2={"呼入电话总数",reportResult.getBeiCallOne(),reportResult.getBeiCallTwo(),reportResult.getBeiCallThree()};
		String[] ss3={"累计通话次数",reportResult.getCountCallOne(),reportResult.getCountCallTwo(),reportResult.getCountCallThree()};
		String[] ss4={"累计通话时长",reportResult.getOneMonthTime(),reportResult.getTwoMonthTime(),reportResult.getThreeMonthTime()};
		String[] ss5={"平均消费金额",reportResult.getOneMonthFee(),reportResult.getTwoMonthFee(),reportResult.getThreeMonthFee()};
		String[] ss6={"与信用卡中心通话时长",reportResult.getXinYongOneTime(),reportResult.getXinYongTwoTime(),reportResult.getXinYongThreeTime()};
		String[] ss7={"与信用卡中心通话次数",reportResult.getXinYongOneCount(),reportResult.getXinYongTwoCount(),reportResult.getXinYongThreeCount()};
		String[] ss8={"最频繁三个号码",reportResult.getResOneList(),reportResult.getResTwoList(),reportResult.getResThreeList()};
		list.add(ss1);
		list.add(ss2);
		list.add(ss3);
		list.add(ss4);
		list.add(ss5);
		list.add(ss6);
		list.add(ss7);
		list.add(ss8);
		
		
		
		//写出一个pdf的文档文件
		try {
			//1.创建一个文档
			Rectangle rectPageSize = new Rectangle(PageSize.A4);// A4纸张  （,a4大小是1487x2105像素）
	        Document document = new Document(rectPageSize, 40, 40, 40, 40);// 上、下、左、右间距  ，像素
			//2.指定文档的输出的位置
	        //获取当前时间戳         
		    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");    
		    String temp = sf.format(new Date());
		    String reportUrl = PropertiesUtils.getProperty("reportUrl");
		    String report = PropertiesUtils.getProperty("getReport_url");
			PdfWriter.getInstance(document, new FileOutputStream(new File(reportUrl,temp+"评分报告.pdf")));
			String result=report+temp+"评分报告.pdf";
			request.setAttribute("result", result);
			//3.打开文档
			document.open();
			//4.准备开始写入内容
			// 设置文档字体(宋体)（使其支持中文）
//					BaseFont baseFontChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
			BaseFont baseFontChinese = BaseFont.createFont(AsianFontMapper.ChineseSimplifiedFont, 
					AsianFontMapper.ChineseSimplifiedEncoding_H, 
					//字体是否内嵌
					BaseFont.NOT_EMBEDDED);
			 //设置字体
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);   
//            com.itextpdf.text.Font FontChinese24 = new com.itextpdf.text.Font(bfChinese, 24, com.itextpdf.text.Font.BOLD);
//            com.itextpdf.text.Font FontChinese18 = new com.itextpdf.text.Font(bfChinese, 18, com.itextpdf.text.Font.BOLD); 
//            com.itextpdf.text.Font FontChinese16 = new com.itextpdf.text.Font(bfChinese, 16, com.itextpdf.text.Font.BOLD);
//            com.itextpdf.text.Font FontChinese12 = new com.itextpdf.text.Font(bfChinese, 12, com.itextpdf.text.Font.NORMAL);
//            com.itextpdf.text.Font FontChinese11Bold = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.BOLD);
            com.itextpdf.text.Font FontChinese11 = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.ITALIC);
            com.itextpdf.text.Font FontChinese11Normal = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.NORMAL);
			
			//====文档标题
			//设置文档标题字体
			Font headerFont=new Font(baseFontChinese, 30, Font.BOLD, BaseColor.RED);
			//构建一个段落
			Paragraph headerParagraph=new Paragraph("评分报告", headerFont);
			headerParagraph.setAlignment(Paragraph.ALIGN_CENTER);
			document.add(headerParagraph);
			// 加入空行
			Paragraph blankRow1 = new Paragraph(18f, " ", FontChinese11);
			document.add(blankRow1);
			
			PdfPTable table1 = new PdfPTable(3);
			int width1[] = { 35, 40, 25 };
			table1.setWidths(width1);
			
			PdfPCell cell11 = new PdfPCell(new Paragraph("报告编号：" + temp, FontChinese11Normal));
			Date date = new Date();       
			Timestamp nowdate = new Timestamp(date.getTime());
			PdfPCell cell12 = new PdfPCell(new Paragraph("报告时间：" + nowdate, FontChinese11Normal));
			PdfPCell cell13 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
			cell11.setBorder(0);
			cell12.setBorder(0);
			cell13.setBorder(0);
			table1.addCell(cell11);
			table1.addCell(cell12);
			table1.addCell(cell13);
			document.add(table1);
			// 加入空行
			Paragraph blankRow = new Paragraph(18f, " ", FontChinese11);
			document.add(blankRow);
			
			PdfPTable table2 = new PdfPTable(3);
			int width2[] = { 35, 40, 25 };
			table2.setWidths(width2);
			PdfPCell cell21 = new PdfPCell(new Paragraph("代表数据一致：" + "一致", FontChinese11Normal));
			PdfPCell cell22 = new PdfPCell(new Paragraph("代表数据不一致：" + "不一致", FontChinese11Normal));
			PdfPCell cell23 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
			cell21.setBorder(0);
			cell22.setBorder(0);
			cell23.setBorder(0);
			table2.addCell(cell21);
			table2.addCell(cell22);
			table2.addCell(cell23);
			document.add(table2);
			// 加入空行
			Paragraph blankRow2 = new Paragraph(18f, " ", FontChinese11);
			document.add(blankRow2);
			
			//====文档副标题
			Font header2Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
			//构建一个段落
			Paragraph header2Paragraph=new Paragraph("评分结果", header2Font);
			header2Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
			header2Paragraph.setLeading(29f);//设置行间距：面空白宽度  
			document.add(header2Paragraph);
			
			//====文档副标题
			Font header21Font=new Font(baseFontChinese, 15, Font.NORMAL, BaseColor.BLACK);
			//构建一个段落
			Paragraph header21Paragraph=new Paragraph("总分："+reportResult.getScoreSum(), header21Font);
			header21Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
			header21Paragraph.setLeading(29f);//设置行间距：面空白宽度  
			document.add(header21Paragraph);
			
			//====文档副标题
			Font header22Font=new Font(baseFontChinese, 30, Font.NORMAL, BaseColor.BLUE);
			//构建一个段落
			Paragraph header22Paragraph=new Paragraph(reportResult.getScore(), header22Font);
			header22Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
			header22Paragraph.setLeading(29f);//设置行间距：面空白宽度  
			document.add(header22Paragraph);
			
			if(reportResult.getNameOnCard()!=null){
				
				//====银行卡
				Font header3Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
				//构建一个段落
				Paragraph header3Paragraph=new Paragraph("银行卡", header3Font);
				header3Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header3Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header3Paragraph);
				
				//====文档三级标题
				Font header31Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header31Paragraph=new Paragraph("基本信息", header31Font);
				header31Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header31Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header31Paragraph);
				
				PdfPTable table31 = new PdfPTable(3);
				int width31[] = { 40, 35, 25 };
				table31.setWidths(width31);
				PdfPCell cell321 = new PdfPCell(new Paragraph("姓名：" + reportResult.getNameOnCard(), FontChinese11Normal));
				PdfPCell cell322 = new PdfPCell(new Paragraph("数据匹配：" + "匹配", FontChinese11Normal));
				PdfPCell cell323 = new PdfPCell(new Paragraph("卡片类型：" + "储蓄卡", FontChinese11Normal));
				cell321.setBorder(0);
				cell322.setBorder(0);
				cell323.setBorder(0);
				table31.addCell(cell321);
				table31.addCell(cell322);
				table31.addCell(cell323);
				document.add(table31);
				// 加入空行
				Paragraph blankRow31 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow31);
				
				PdfPTable table32 = new PdfPTable(3);
				int width32[] = { 40, 35, 25 };
				table32.setWidths(width32);
				PdfPCell cell331 = new PdfPCell(new Paragraph("卡片后四位：" + reportResult.getCardNo(), FontChinese11Normal));
				PdfPCell cell332 = new PdfPCell(new Paragraph("余额" + reportResult.getnutBalance1(), FontChinese11Normal));
				PdfPCell cell333 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell331.setBorder(0);
				cell332.setBorder(0);
				cell333.setBorder(0);
				table32.addCell(cell331);
				table32.addCell(cell332);
				table32.addCell(cell333);
				document.add(table32);
				// 加入空行
				Paragraph blankRow32 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow32);
			}
			if(reportResult.getChsiRealname()!=null){
				
				//====文档副标题
				Font header4Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
				//构建一个段落
				Paragraph header4Paragraph=new Paragraph("学信网", header4Font);
				header4Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header4Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header4Paragraph);
				
				//====文档三级标题
				Font header41Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header41Paragraph=new Paragraph("学历信息", header41Font);
				header41Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header41Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header41Paragraph);
				
				PdfPTable table41 = new PdfPTable(3);
				int width41[] = { 40, 35, 25 };
				table41.setWidths(width41);
				//String imagePath2 = "E:/1.png";
				//Image image1 = Image.getInstance(imagePath2);
				PdfPCell cell411 = new PdfPCell(new Paragraph("姓名：" + reportResult.getChsiRealname(), FontChinese11Normal));
				PdfPCell cell412 = new PdfPCell(new Paragraph("身份证：" + reportResult.getChsiCard_id(), FontChinese11Normal));
				cell411.setBorder(0);
				cell412.setBorder(0);
				//table41.addCell(image1);
				table41.addCell(cell411);
				table41.addCell(cell412);
				document.add(table41);
				// 加入空行
				Paragraph blankRow41 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow41);
				
				
				PdfPTable table42 = new PdfPTable(3);
				int width42[] = { 40, 35, 25 };
				table42.setWidths(width42);
				PdfPCell cell421 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell422 = new PdfPCell(new Paragraph("毕业院校：" + reportResult.getChsiSchool(), FontChinese11Normal));
				PdfPCell cell423 = new PdfPCell(new Paragraph("学历：" + reportResult.getChsiEdu_level(), FontChinese11Normal));
				cell421.setBorder(0);
				cell422.setBorder(0);
				cell423.setBorder(0);
				table42.addCell(cell421);
				table42.addCell(cell422);
				table42.addCell(cell423);
				document.add(table42);
				// 加入空行
				Paragraph blankRow42 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow42);
				
				PdfPTable table43 = new PdfPTable(3);
				int width43[] = { 40, 35, 25 };
				table43.setWidths(width43);
				PdfPCell cell431 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell432 = new PdfPCell(new Paragraph("入学时间：" + reportResult.getEntrance_date(), FontChinese11Normal));
				PdfPCell cell433 = new PdfPCell(new Paragraph("毕业时间：" + reportResult.getGraduate_date(), FontChinese11Normal));
				cell431.setBorder(0);
				cell432.setBorder(0);
				cell433.setBorder(0);
				table43.addCell(cell431);
				table43.addCell(cell432);
				table43.addCell(cell433);
				document.add(table43);
				// 加入空行
				Paragraph blankRow43 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow43);
				
				PdfPTable table44 = new PdfPTable(3);
				int width44[] = { 40, 35, 25 };
				table44.setWidths(width44);
				PdfPCell cell441 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell442 = new PdfPCell(new Paragraph("专业：" + reportResult.getMajor(), FontChinese11Normal));
				PdfPCell cell443 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell441.setBorder(0);
				cell442.setBorder(0);
				cell443.setBorder(0);
				table44.addCell(cell441);
				table44.addCell(cell442);
				table44.addCell(cell443);
				document.add(table44);
				// 加入空行
				Paragraph blankRow44 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow44);
				
				PdfPTable table45 = new PdfPTable(3);
				int width45[] = { 40, 35, 25 };
				table45.setWidths(width45);
				PdfPCell cell451 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell452 = new PdfPCell(new Paragraph("学历类型：" + "普通", FontChinese11Normal));
				PdfPCell cell453 = new PdfPCell(new Paragraph("毕业结论：" + "毕业", FontChinese11Normal));
				cell451.setBorder(0);
				cell452.setBorder(0);
				cell453.setBorder(0);
				table45.addCell(cell451);
				table45.addCell(cell452);
				table45.addCell(cell453);
				document.add(table45);
				// 加入空行
				Paragraph blankRow45 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow45);
			}
			if(reportResult.getGjjReal_name()!=null){
				
				//====公积金
				Font header5Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
				//构建一个段落
				Paragraph header5Paragraph=new Paragraph("公积金", header5Font);
				header5Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header5Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header5Paragraph);
				
				//====文档三级标题
				Font header51Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header51Paragraph=new Paragraph("基本信息", header51Font);
				header51Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header51Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header51Paragraph);
				
				PdfPTable table51 = new PdfPTable(3);
				int width51[] = { 40, 35, 25 };
				table51.setWidths(width51);
				PdfPCell cell521 = new PdfPCell(new Paragraph("姓名：" + reportResult.getGjjReal_name(), FontChinese11Normal));
				PdfPCell cell522 = new PdfPCell(new Paragraph("移动电话：" + reportResult.getGjjUser_mobile(), FontChinese11Normal));
				PdfPCell cell523 = new PdfPCell(new Paragraph("余额：" + reportResult.getBalance(), FontChinese11Normal));
				cell521.setBorder(0);
				cell522.setBorder(0);
				cell523.setBorder(0);
				table51.addCell(cell521);
				table51.addCell(cell522);
				table51.addCell(cell523);
				document.add(table51);
				// 加入空行
				Paragraph blankRow51 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow51);
				
				PdfPTable table52 = new PdfPTable(3);
				int width52[] = { 40, 35, 25 };
				table52.setWidths(width52);
				PdfPCell cell531 = new PdfPCell(new Paragraph("缴存状态：" + reportResult.getTingType(), FontChinese11Normal));
				PdfPCell cell532 = new PdfPCell(new Paragraph("身份证" + reportResult.getGjjIdentity_code(), FontChinese11Normal));
				PdfPCell cell533 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell531.setBorder(0);
				cell532.setBorder(0);
				cell533.setBorder(0);
				table52.addCell(cell531);
				table52.addCell(cell532);
				table52.addCell(cell533);
				document.add(table52);
				// 加入空行
				Paragraph blankRow52 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow52);
			}
			if(reportResult.getSheUser_name()!=null){
				
				//====社保
				Font header6Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
				//构建一个段落
				Paragraph header6Paragraph=new Paragraph("社保", header6Font);
				header6Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header6Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header6Paragraph);
				
				//====文档三级标题
				Font header61Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header61Paragraph=new Paragraph("基本信息", header61Font);
				header61Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header61Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header61Paragraph);
				
				//基本信息
				PdfPTable table61 = new PdfPTable(3);
				int width61[] = { 40, 35, 25 };
				table61.setWidths(width61);
				PdfPCell cell611 = new PdfPCell(new Paragraph("身份证：" + reportResult.getSheUser_name(), FontChinese11Normal));
				PdfPCell cell612 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell613 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell611.setBorder(0);
				cell612.setBorder(0);
				cell613.setBorder(0);
				table61.addCell(cell611);
				table61.addCell(cell612);
				table61.addCell(cell613);
				document.add(table61);
				// 加入空行
				Paragraph blankRow61 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow61);
				
				PdfPTable table62 = new PdfPTable(3);
				int width62[] = { 40, 35, 25 };
				table62.setWidths(width62);
				PdfPCell cell621 = new PdfPCell(new Paragraph("姓名：" + reportResult.getSheReal_name(), FontChinese11Normal));
				PdfPCell cell622 = new PdfPCell(new Paragraph("移动电话" + reportResult.getSheUser_mobile(), FontChinese11Normal));
				PdfPCell cell623 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell621.setBorder(0);
				cell622.setBorder(0);
				cell623.setBorder(0);
				table62.addCell(cell621);
				table62.addCell(cell622);
				table62.addCell(cell623);
				document.add(table62);
				// 加入空行
				Paragraph blankRow62 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow62);
				
				PdfPTable table63 = new PdfPTable(3);
				int width63[] = { 40, 35, 25 };
				table63.setWidths(width63);
				PdfPCell cell631 = new PdfPCell(new Paragraph("缴存状态：" + reportResult.getShe_baoType(), FontChinese11Normal));
				PdfPCell cell632 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell633 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell631.setBorder(0);
				cell632.setBorder(0);
				cell633.setBorder(0);
				table63.addCell(cell631);
				table63.addCell(cell632);
				table63.addCell(cell633);
				document.add(table63);
				// 加入空行
				Paragraph blankRow63 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow63);
			}
			
			if (reportResult.getYysReal_name()!=null) {
				
				//====运营商
				Font header7Font=new Font(baseFontChinese, 10, Font.NORMAL, BaseColor.BLACK);
				//构建一个段落
				Paragraph header7Paragraph=new Paragraph("运营商", header7Font);
				header7Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header7Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header7Paragraph);
				
				//====文档三级标题
				Font header71Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header71Paragraph=new Paragraph("用户信息", header71Font);
				header71Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header71Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header71Paragraph);
				
				//运营商
				PdfPTable table71 = new PdfPTable(3);
				int width71[] = { 40, 35, 25 };
				table71.setWidths(width71);
				PdfPCell cell711 = new PdfPCell(new Paragraph("姓名：" + reportResult.getYysReal_name(), FontChinese11Normal));
				PdfPCell cell712 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell713 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell711.setBorder(0);
				cell712.setBorder(0);
				cell713.setBorder(0);
				table71.addCell(cell711);
				table71.addCell(cell712);
				table71.addCell(cell713);
				document.add(table71);
				// 加入空行
				Paragraph blankRow71 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow71);
				
				// table7
				PdfPTable table72 = new PdfPTable(3);
				int width72[] = { 40, 35, 25 };
				table72.setWidths(width72);
				PdfPCell cell721 = new PdfPCell(new Paragraph("身份证：" + reportResult.getYysIdentity_code(), FontChinese11Normal));
				PdfPCell cell722 = new PdfPCell(new Paragraph("身份证有效：" + "有效", FontChinese11Normal));
				PdfPCell cell723 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell721.setBorder(0);
				cell722.setBorder(0);
				cell723.setBorder(0);
				table72.addCell(cell721);
				table72.addCell(cell722);
				table72.addCell(cell723);
				document.add(table72);
				// 加入空行
				Paragraph blankRow72 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow72);
				
				// table73
				PdfPTable table73 = new PdfPTable(3);
				int width73[] = { 40, 35, 25 };
				table73.setWidths(width73);
				PdfPCell cell731 = new PdfPCell(new Paragraph("性别：" + "未知", FontChinese11Normal));
				PdfPCell cell732 = new PdfPCell(new Paragraph("年龄：" + "未知", FontChinese11Normal));
				PdfPCell cell733 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell731.setBorder(0);
				cell732.setBorder(0);
				cell733.setBorder(0);
				table73.addCell(cell731);
				table73.addCell(cell732);
				table73.addCell(cell733);
				document.add(table73);
				// 加入空行
				Paragraph blankRow73 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow73);
				
				// table74
				PdfPTable table74 = new PdfPTable(3);
				int width74[] = { 40, 35, 25 };
				table74.setWidths(width74);
				PdfPCell cell741 = new PdfPCell(new Paragraph("联系电话：" + reportResult.getYysUser_mobile(), FontChinese11Normal));
				PdfPCell cell742 = new PdfPCell(new Paragraph("邮箱地址：" + "未知", FontChinese11Normal));
				PdfPCell cell743 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell741.setBorder(0);
				cell742.setBorder(0);
				cell743.setBorder(0);
				table74.addCell(cell741);
				table74.addCell(cell742);
				table74.addCell(cell743);
				document.add(table74);
				// 加入空行
				Paragraph blankRow74 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow74);
				
				// table75
				PdfPTable table75 = new PdfPTable(3);
				int width75[] = { 40, 35, 25 };
				table75.setWidths(width75);
				PdfPCell cell751 = new PdfPCell(new Paragraph("联系地址：" + "未知", FontChinese11Normal));
				PdfPCell cell752 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell753 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell751.setBorder(0);
				cell752.setBorder(0);
				cell753.setBorder(0);
				table75.addCell(cell751);
				table75.addCell(cell752);
				table75.addCell(cell753);
				document.add(table75);
				// 加入空行
				Paragraph blankRow75 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow75);
				
				//====文档三级标题
				Font header72Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header72Paragraph=new Paragraph("账户信息", header72Font);
				header72Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header72Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header72Paragraph);
				
				//运营商
				PdfPTable table712 = new PdfPTable(3);
				int width712[] = { 40, 35, 25 };
				table712.setWidths(width712);
				PdfPCell cell7112 = new PdfPCell(new Paragraph("电话：" + reportResult.getYysUser_mobile(), FontChinese11Normal));
				PdfPCell cell7122 = new PdfPCell(new Paragraph("实名认证：" + "已实名", FontChinese11Normal));
				PdfPCell cell7132 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell7112.setBorder(0);
				cell7122.setBorder(0);
				cell7132.setBorder(0);
				table712.addCell(cell7112);
				table712.addCell(cell7122);
				table712.addCell(cell7132);
				document.add(table712);
				// 加入空行
				Paragraph blankRow712 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow712);
				
				// table7
				PdfPTable table722 = new PdfPTable(3);
				int width722[] = { 40, 35, 25 };
				table722.setWidths(width722);
				PdfPCell cell7212 = new PdfPCell(new Paragraph("运营商：" + reportResult.getYysChannel_src(), FontChinese11Normal));
				PdfPCell cell7222 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell7232 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell7212.setBorder(0);
				cell7222.setBorder(0);
				cell7232.setBorder(0);
				table722.addCell(cell7212);
				table722.addCell(cell7222);
				table722.addCell(cell7232);
				document.add(table722);
				// 加入空行
				Paragraph blankRow722 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow722);
				
				// table73
				PdfPTable table732 = new PdfPTable(3);
				int width732[] = { 40, 35, 25 };
				table73.setWidths(width732);
				PdfPCell cell7312 = new PdfPCell(new Paragraph("账户状态：" + "正常", FontChinese11Normal));
				PdfPCell cell7322 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell7332 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell7312.setBorder(0);
				cell7322.setBorder(0);
				cell7332.setBorder(0);
				table732.addCell(cell7312);
				table732.addCell(cell7322);
				table732.addCell(cell7332);
				document.add(table732);
				// 加入空行
				Paragraph blankRow732 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow732);
				
				// table74
				PdfPTable table742 = new PdfPTable(3);
				int width742[] = { 40, 35, 25 };
				table74.setWidths(width742);
				PdfPCell cell7412 = new PdfPCell(new Paragraph("账户余额：" + reportResult.getYysAccount_balance(), FontChinese11Normal));
				PdfPCell cell7422 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				PdfPCell cell7432 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell7412.setBorder(0);
				cell7422.setBorder(0);
				cell7432.setBorder(0);
				table742.addCell(cell7412);
				table742.addCell(cell7422);
				table742.addCell(cell7432);
				document.add(table742);
				// 加入空行
				Paragraph blankRow742 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow742);
				
				// table75
				PdfPTable table752 = new PdfPTable(3);
				int width752[] = { 40, 35, 25 };
				table752.setWidths(width752);
				PdfPCell cell7512 = new PdfPCell(new Paragraph("入网时间：" + reportResult.getNetTime(), FontChinese11Normal));
				PdfPCell cell7522 = new PdfPCell(new Paragraph("入网时间大于三个月：" + "是", FontChinese11Normal));
				PdfPCell cell7532 = new PdfPCell(new Paragraph("" + "", FontChinese11Normal));
				cell7512.setBorder(0);
				cell7522.setBorder(0);
				cell7532.setBorder(0);
				table752.addCell(cell7512);
				table752.addCell(cell7522);
				table752.addCell(cell7532);
				document.add(table752);
				// 加入空行
				Paragraph blankRow752 = new Paragraph(18f, " ", FontChinese11);
				document.add(blankRow752);
				
				
				//====文档三级标题
				Font header73Font=new Font(baseFontChinese, 7, Font.NORMAL, BaseColor.GRAY);
				//构建一个段落
				Paragraph header73Paragraph=new Paragraph("通话统计", header73Font);
				header73Paragraph.setAlignment(Paragraph.ALIGN_LEFT);
				header73Paragraph.setLeading(29f);//设置行间距：面空白宽度  
				document.add(header73Paragraph);
				
				//====文档正文
				//表格头部字体
				Font tableHeaderFont = new Font(baseFontChinese, 15, Font.BOLD, BaseColor.BLACK);
				//表格内容字体
				Font tableBodyFont = new Font(baseFontChinese, 15, Font.NORMAL, BaseColor.BLACK);
				
				//构建一个表格(表格的初始化)
				// 创建一个有6列的表格 
				PdfPTable pdfPTable = new PdfPTable(4);
				
				pdfPTable.setSpacingBefore(29f);//设置表格到上面段落的高度
				//设置表格的宽度和高度-略
				//锁定表格宽度，以便下面指定表格的具体宽度，否则根据文字自适应宽度
				pdfPTable.setLockedWidth(true);
				//以下两个属性必须依赖于上面的锁定宽度属性
				pdfPTable.setTotalWidth(800);// 宽度
				pdfPTable.setTotalWidth(new float[]{ 100, 120, 120,120});
				pdfPTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // 水平对齐方式
				pdfPTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); // 垂直对齐方式
				
				//表头内容
				pdfPTable.addCell(new PdfPCell(new Phrase("", tableHeaderFont)));
				pdfPTable.addCell(new PdfPCell(new Phrase("1个月", tableHeaderFont)));
				pdfPTable.addCell(new PdfPCell(new Phrase("2个月", tableHeaderFont)));
				pdfPTable.addCell(new PdfPCell(new Phrase("3个月", tableHeaderFont)));
				//表格内容
				PdfPCell cell= new PdfPCell();
				cell.setPadding(5f);
				for (String[] ss : list) {
					cell.setPhrase(new Phrase(ss[0], tableBodyFont));
					pdfPTable.addCell(cell);
					cell.setPhrase(new Phrase(ss[1], tableBodyFont));
					pdfPTable.addCell(cell);
					cell.setPhrase(new Phrase(ss[2], tableBodyFont));
					pdfPTable.addCell(cell);
					cell.setPhrase(new Phrase(ss[3], tableBodyFont));
					pdfPTable.addCell(cell);
				}
				//段落添加到文档
				document.add(pdfPTable);
			}
			
			//5.释放资源
			document.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (DocumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		log.info("打印完成");
		return "/buyer/printSuccess";
	}
}

